package com.zx.feign;

import com.zx.entity.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author jack.wu
 * @version 1.0
 * @date 2020-03-08
 */
//@FeignClient(value = "service-product", fallback = ProductFeignFallback.class)
//@FeignClient(value = "service-product", fallbackFactory = ProductFeignFallbackFactory.class)
@FeignClient(value = "service-product")
public interface ProductFeignClient {

    /**
     * 查询商品
     *
     * @param pid 商品id
     * @return 商品信息
     */
    @GetMapping("/product/product/{pid}")
    Product findById(@PathVariable("pid") Integer pid);

    /**
     * 扣库存
     *
     * @param pid 商品id
     * @param num 减少库存数
     */
    @GetMapping("/product/reduceInventory")
    void reduceInventory(@RequestParam("pid") Integer pid, @RequestParam("num") int num);
}
